import 'package:flutter/material.dart';
import 'package:new_obj/squeraItems//FocusInfos.dart';
import 'package:new_obj/squeraItems/commendInfo.dart';

class _TabData {
  final Widget tab;
  final Widget body;

  _TabData({this.tab, this.body});
}

final _tabDataList = <_TabData>[
  _TabData(tab: Text("推荐"), body: commendInfo()),
  _TabData(tab: Text("关注"), body: FocusInfos()),
];

class squareInfo extends StatefulWidget {
  @override
  _squareInfo createState() => _squareInfo();
}

class _squareInfo extends State<squareInfo> {
  final tabBarList = _tabDataList.map((item) => item.tab).toList();
  final tabBarViewList = _tabDataList.map((item) => item.body).toList();

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return DefaultTabController(
      length: tabBarList.length,
      child: Column(
        children: <Widget>[
          Container(
              width: double.infinity,
              height: 80,
              padding: EdgeInsets.fromLTRB(20, 24, 0, 0),
              alignment: Alignment.centerLeft,
              color: Colors.teal,
              child: TabBar(
                isScrollable: true,
                indicatorColor: Colors.white,
                indicatorSize: TabBarIndicatorSize.label,
                unselectedLabelColor: Colors.black,
                unselectedLabelStyle: TextStyle(fontSize: 18),
                labelColor: Colors.white,
                labelStyle: TextStyle(fontSize: 20),
                tabs: tabBarList,
              )),
          Expanded(
            child: TabBarView(
              children: tabBarViewList,
            ),
          )
        ],
      ),
    );
  }
}
